From 3b15c8b23229580b13e638720c9a9fe1eda5b1eb Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 5 Feb 2004 23:45:21 +0000 Subject: [PATCH] Add a finalize function to plug a few memory leaks. (#133544, Morten Fri Feb 6 00:45:16 2004 Matthias Clasen * gtk/gtkcombobox.c (gtk_combo_box_finalize): Add a finalize function to plug a few memory leaks. (#133544, Morten Welinder) --- ChangeLog | 5 +++++ ChangeLog.pre-2-10 | 5 +++++ ChangeLog.pre-2-4 | 5 +++++ ChangeLog.pre-2-6 | 5 +++++ ChangeLog.pre-2-8 | 5 +++++ gtk/gtkcombobox.c | 29 +++++++++++++++++++++++++++-- 6 files changed, 52 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1d5a3d5b97..b386790a72 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Fri Feb 6 00:45:16 2004 Matthias Clasen + + * gtk/gtkcombobox.c (gtk_combo_box_finalize): Add a finalize + function to plug a few memory leaks. (#133544, Morten Welinder) + Fri Feb 6 00:15:38 2004 Matthias Clasen * gtk/gtkcomboboxentry.c (gtk_combo_box_entry_mnemonic_activate): diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 1d5a3d5b97..b386790a72 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,8 @@ +Fri Feb 6 00:45:16 2004 Matthias Clasen + + * gtk/gtkcombobox.c (gtk_combo_box_finalize): Add a finalize + function to plug a few memory leaks. (#133544, Morten Welinder) + Fri Feb 6 00:15:38 2004 Matthias Clasen * gtk/gtkcomboboxentry.c (gtk_combo_box_entry_mnemonic_activate): diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 1d5a3d5b97..b386790a72 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,8 @@ +Fri Feb 6 00:45:16 2004 Matthias Clasen + + * gtk/gtkcombobox.c (gtk_combo_box_finalize): Add a finalize + function to plug a few memory leaks. (#133544, Morten Welinder) + Fri Feb 6 00:15:38 2004 Matthias Clasen * gtk/gtkcomboboxentry.c (gtk_combo_box_entry_mnemonic_activate): diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 1d5a3d5b97..b386790a72 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,8 @@ +Fri Feb 6 00:45:16 2004 Matthias Clasen + + * gtk/gtkcombobox.c (gtk_combo_box_finalize): Add a finalize + function to plug a few memory leaks. (#133544, Morten Welinder) + Fri Feb 6 00:15:38 2004 Matthias Clasen * gtk/gtkcomboboxentry.c (gtk_combo_box_entry_mnemonic_activate): diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 1d5a3d5b97..b386790a72 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,8 @@ +Fri Feb 6 00:45:16 2004 Matthias Clasen + + * gtk/gtkcombobox.c (gtk_combo_box_finalize): Add a finalize + function to plug a few memory leaks. (#133544, Morten Welinder) + Fri Feb 6 00:15:38 2004 Matthias Clasen * gtk/gtkcomboboxentry.c (gtk_combo_box_entry_mnemonic_activate): diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c index c666578e8e..2534ac84ed 100644 --- a/gtk/gtkcombobox.c +++ b/gtk/gtkcombobox.c @@ -136,6 +136,7 @@ static void gtk_combo_box_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *spec); +static void gtk_combo_box_finalize (GObject *object); static void gtk_combo_box_style_set (GtkWidget *widget, GtkStyle *previous_style, @@ -322,6 +323,7 @@ gtk_combo_box_class_init (GtkComboBoxClass *klass) widget_class->mnemonic_activate = gtk_combo_box_mnemonic_activate; object_class = (GObjectClass *)klass; + object_class->finalize = gtk_combo_box_finalize; object_class->set_property = gtk_combo_box_set_property; object_class->get_property = gtk_combo_box_get_property; @@ -2376,7 +2378,7 @@ gtk_combo_box_cell_layout_reorder (GtkCellLayout *layout, GtkWidget * gtk_combo_box_new (void) { - return GTK_WIDGET (g_object_new (gtk_combo_box_get_type (), NULL)); + return GTK_WIDGET (g_object_new (GTK_TYPE_COMBO_BOX, NULL)); } /** @@ -2396,7 +2398,7 @@ gtk_combo_box_new_with_model (GtkTreeModel *model) g_return_val_if_fail (GTK_IS_TREE_MODEL (model), NULL); - combo_box = GTK_COMBO_BOX (g_object_new (gtk_combo_box_get_type (), + combo_box = GTK_COMBO_BOX (g_object_new (GTK_TYPE_COMBO_BOX, "model", model, NULL)); @@ -2839,3 +2841,26 @@ gtk_combo_box_mnemonic_activate (GtkWidget *widget, return TRUE; } + +static void +gtk_combo_box_finalize (GObject *object) +{ + GtkComboBox *combo_box = GTK_COMBO_BOX (object); + + if (GTK_IS_MENU (combo_box->priv->popup_widget)) + gtk_combo_box_menu_destroy (combo_box); + + if (GTK_IS_TREE_VIEW (combo_box->priv->tree_view)) + gtk_combo_box_list_destroy (combo_box); + + if (combo_box->priv->popup_window) + gtk_widget_destroy (combo_box->priv->popup_window); + + if (combo_box->priv->model) + g_object_unref (combo_box->priv->model); + + g_slist_foreach (combo_box->priv->cells, (GFunc)g_free, NULL); + g_slist_free (combo_box->priv->cells); + + G_OBJECT_CLASS (parent_class)->finalize (object); +} -- 2.30.2